package com.lanxum.zuul;

import com.lanxum.zuul.filter.AccessFilter;
import com.lanxum.zuul.filter.CookieFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableZuulProxy
public class ZuulServerApplication {

	public static void main(String[] args) {
		SpringApplication.run(ZuulServerApplication.class, args);
	}

	/**
	 * 当 zuul.ignoredServices: 不为 '*' 时，此配置生效
	 * 在eureka中注册的服务，默认会被添加到route
	 * 例如服务为uuu，添加后route为
	 * Route(id=api/uuu, fullPath=/api/uuu/**, path=/**, location=uuu, prefix=/api/uuu, retryable=null, sensitiveHeaders=[], customSensitiveHeaders=false)
	 * 使用/api/uuu/可以访问到uuu的功能
	 * @return
	 */
//	@Bean
//	public PatternServiceRouteMapper serviceRouteMapper() {
//		return new PatternServiceRouteMapper(
//				"(?<name>^.+)",
//				"${name}");
//	}

	@Bean
	public AccessFilter accessFilter() {
		return new AccessFilter();
	}

	@Bean
	public CookieFilter cookieFilter() {
		return new CookieFilter();
	}
}
